package co.yixiang.hw.rest;


import co.yixiang.annotation.AnonymousAccess;
import co.yixiang.aop.log.Log;
import co.yixiang.hw.service.YxSystemGroupDataService;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
* @author Walert
* @date 2020-02-12
*/
@Api(tags = "首页接口API")
@RestController
@RequestMapping("/api/index")
public class YxIndexController extends BaseController {

    private final YxSystemGroupDataService yxSystemGroupDataService;

    public YxIndexController(YxSystemGroupDataService yxSystemGroupDataService) {
        this.yxSystemGroupDataService = yxSystemGroupDataService;
    }

    /**
     * 首页限时折扣
     * @param params
     * @return
     */
    @Log("首页限时折扣")
    @ApiOperation("首页限时折扣")
    @PostMapping(value = "/timeLimitDiscount")
    @AnonymousAccess
    public ResponseEntity<Object> timeLimitDiscount(@RequestBody JSONObject params){
        return new ResponseEntity<>(yxSystemGroupDataService.getTimeLimitDiscount(),HttpStatus.OK);
    }


    /**
     * 首页轮播图
     * @param params
     * @return
     */
    @Log("首页banner获取")
    @ApiOperation("首页banner获取")
    @PostMapping(value = "/banner")
    @AnonymousAccess
    public ResponseEntity<Object> indexBanner(@RequestBody JSONObject params){
        return new ResponseEntity<>(yxSystemGroupDataService.getIndexBannerList(),HttpStatus.OK);
    }

    /**
     * 本周爆款
     * @param params
     * @return
     */
    @Log("本周爆款")
    @ApiOperation("本周爆款")
    @PostMapping(value = "/week-hot")
    @AnonymousAccess
    public ResponseEntity<Object> weekHot(@RequestBody JSONObject params){
        return new ResponseEntity<>(yxSystemGroupDataService.getWeekHot(),HttpStatus.OK);
    }


    /**
     * 往期推荐
     * @param params
     * @return
     */
    @Log("往期推荐")
    @ApiOperation("往期推荐")
    @PostMapping(value = "/history-recommend")
    @AnonymousAccess
    public ResponseEntity<Object> historyRecommend(@RequestBody JSONObject params){
        return new ResponseEntity<>(yxSystemGroupDataService.getHistoryRecommend(),HttpStatus.OK);
    }


    /**
     * 分类商品推荐位
     * @param params
     * @return
     */
    @Log("分类商品推荐位")
    @ApiOperation("分类商品推荐位")
    @PostMapping(value = "/cate-goods")
    @AnonymousAccess
    public ResponseEntity<Object> cateGoods(@RequestBody JSONObject params){
        return new ResponseEntity<>(yxSystemGroupDataService.getCateGoods(),HttpStatus.OK);
    }

    /**
     * 分类商品推荐位
     * @param params
     * @return
     */
    @Log("分类商品推荐位")
    @ApiOperation("分类商品推荐位")
    @PostMapping(value = "/index-title")
    @AnonymousAccess
    public ResponseEntity<Object> indexTitle(@RequestBody JSONObject params){
        return new ResponseEntity<>(yxSystemGroupDataService.getIndexTitle(),HttpStatus.OK);
    }


    /**
     * 获取首页menus
     * @param params
     * @return
     */
    @Log("首页HomeMenus")
    @ApiOperation("首页HomeMenus")
    @PostMapping(value = "/index-menus")
    @AnonymousAccess
    public ResponseEntity<Object> indexMenus(@RequestBody JSONObject params){
        return new ResponseEntity<>(yxSystemGroupDataService.getIndexHomeMenusList(),HttpStatus.OK);
    }


}
